#ifndef _QUEUE_H_
#define _QUEUE_H_

#include "list.h"

typedef struct {
    int len;
    list_node entries;
} queue_node;

enum event_type {
    EV_READ,
    EV_WRITE,
    EV_ACCEPT,
    EV_CLOSE,
};

enum event_status {
    S_LISTENING = 1,
    S_READING   = 2,
    S_WRITING   = 4,
    S_CLOSING   = 8,
    S_RX_ALLOC  = 16,
    S_TX_ALLOC  = 32,
};

struct event {
    enum event_type type;
    void (* callback)(struct event *);
    int fd;
    int nbytes;
    list_node node;
};

void queue_init(queue_node * queue);
void enqueue(queue_node * queue, struct event * event);
struct event * dequeue(queue_node * queue);

#endif /* _QUEUE_H_ */
